package com.d3works.studio.db.repo;

import com.d3works.meta.MetaStore;
import com.d3works.studio.db.ActionBuilder;
import com.d3works.studio.service.StudioMetaService;
import com.d3works.studio.service.builder.ActionBuilderService;
import com.google.inject.Inject;

public class ActionBuilderRepo extends ActionBuilderRepository {

  @Inject private StudioMetaService metaService;

  @Inject private ActionBuilderService builderService;

  @Override
  public ActionBuilder save(ActionBuilder builder) {

    builder = super.save(builder);

    builderService.build(builder);

    return builder;
  }

  @Override
  public void remove(ActionBuilder actionBuilder) {

    metaService.removeMetaActions(actionBuilder.getXmlId());

    MetaStore.clear();

    super.remove(actionBuilder);
  }
}
